/*
 * @Author: Hp_lucky 1063512385@qq.com
 * @Date: 2024-08-29 09:05:47
 * @LastEditors: Hp_lucky 1063512385@qq.com
 * @LastEditTime: 2024-09-19 17:33:40
 * @FilePath: \cocos_frame\assets\script\src\Basic\Model\Tips\TipsDataBase.ts
 */
import { UITransform, Node } from 'cc';
import { BaseRecycle } from '../../Manager/PoolManager';
import { CallBackHandler } from '../PoolObj/CallBackHandler';

export enum TipsObjectType {
  /** 详情信息提示，点击其他地方消失 */
  miniWinTips = 'miniWinTips',
  /** 左边飞出来 */
  flyTipsLeft = 'flyTipsLeft',
  /** 右边飞出来 */
  flyTipsRight = 'flyTipsRight',
  /** 中间飞出来 */
  flyTipsCenter = 'flyTipsCenter',
  /** 中间飞出来 */
  flyBlackTipsCenter = 'flyBlackTipsCenter',
  /** 下拉列表 */
  dropdownList = 'dropdownList',
}

export abstract class TipsDataBase extends BaseRecycle {
  abstract className: TipsObjectType;
  controler?: string;
  callBack?: (...args: unknown[]) => unknown | CallBackHandler;
}

export class MinWinTips extends TipsDataBase {
  className = TipsObjectType.miniWinTips;
  /** 要显示的tip节点 */
  node: Node;
  /** 点击出现的区域 */
  form: UITransform[];
  /** 如果取消区域和出现区域有重叠，可以额外设置取消区域 */
  canelForm?: UITransform[];

  reuse(uuid: string, node: Node, form: UITransform[], canelForm?: UITransform[], callBack?: (...args: unknown[]) => unknown | CallBackHandler) {
    this.controler = uuid;
    this.node = node;
    this.form = form;
    this.canelForm = canelForm;
    this.callBack = callBack;
  }

  unuse() {
    this.node = null;
    this.form = null;
    this.canelForm = null;
    this.callBack = null;
  }
}

/** 从右边飞出来的提示 */
export class FlyRightTipsData extends TipsDataBase {
  className = TipsObjectType.flyTipsRight;
  icon: string;
  title: string;
  details: string;
  reuse(icon: string, title: string, details: string) {
    this.icon = icon;
    this.title = title;
    this.details = details;
  }
  unuse() {}
}

/** 从中间飞出来的提示 */
export class FlyCenterTipsData extends TipsDataBase {
  className = TipsObjectType.flyTipsCenter;
  details: string;
  reuse(details: string) {
    this.details = details;
  }
  unuse() {}
}

/** 从中间飞出来的提示 */
export class FlyBlackCenterTipsData extends TipsDataBase {
  className = TipsObjectType.flyBlackTipsCenter;
  details: string;
  reuse(details: string) {
    this.details = details;
  }
  unuse() {}
}

/** 下拉列表 */
export class DropDownListData extends TipsDataBase {
  className = TipsObjectType.dropdownList;
  controler: string;
  node: Node;
  area: UITransform[];
  data: unknown[];
  judgeFun: (input: string, data: unknown) => boolean;
  onChose: (...args) => void;
  reuse(node: Node, area: UITransform[], data: unknown[], judgeFun, onChose) {
    this.node = node;
    this.controler = node.uuid;
    this.area = area;
    this.data = data;
    this.judgeFun = judgeFun;
    this.onChose = onChose;
  }

  unuse() {}
}
